package com.tobestronger.shouxiespringframework.aop;

import org.aopalliance.intercept.MethodInterceptor;

/**
 * 将代理,拦截,匹配等包装到一个类中,方便在Proxy实现类中使用, 与业务开发中包装入参一个套路
 * <br/>
 * 最终放入容器的是 targetSource中包装的对象的代理对象proxy,
 * 然后执行proxy的某个方法时 会用methodMatcher检查是否需要被拦截,
 * 如果需要,则执行外部提供的 methodInterceptor.
 * 如果不需要,则执行原方法即可.
 */
public class AdvisedSupport {

    /**
     * 表示是否代理class的标识; 是-采用cglib实现(底层继承实现) 否-采用jdk实现(底层使用相同接口实现的类去替换)
     */
    private boolean proxyTargetClass = false;

    /**
     * 被代理的目标对象
     */
    private TargetSource targetSource;

    /**
     * 确定节点后要执行的方法拦截器
     */
    private MethodInterceptor methodInterceptor;

    /**
     * 方法匹配器(检查目标方法是否符合通知条件)
     */
    private MethodMatcher methodMatcher;

    public boolean isProxyTargetClass() {
        return proxyTargetClass;
    }

    public void setProxyTargetClass(boolean proxyTargetClass) {
        this.proxyTargetClass = proxyTargetClass;
    }

    public TargetSource getTargetSource() {
        return targetSource;
    }

    public void setTargetSource(TargetSource targetSource) {
        this.targetSource = targetSource;
    }

    public MethodInterceptor getMethodInterceptor() {
        return methodInterceptor;
    }

    public void setMethodInterceptor(MethodInterceptor methodInterceptor) {
        this.methodInterceptor = methodInterceptor;
    }

    public MethodMatcher getMethodMatcher() {
        return methodMatcher;
    }

    public void setMethodMatcher(MethodMatcher methodMatcher) {
        this.methodMatcher = methodMatcher;
    }
}
